package com.company.repository;

import com.company.model.Company;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * 公司相关Repository
 * Created by Tu on 2017/1/1.
 */
@Repository
public interface CompanyRepository extends CrudRepository<Company, Long>,
    JpaSpecificationExecutor<Company> {

  @Query("FROM Company u WHERE u.name like %:name% and u.deleted = :deleted order by sort desc, updateTime desc")
  List<Company> findCompaniesByName(@Param("name") String name,
      @Param("deleted") int deleted);
}
